package com.jorado.pulsar.client.util;

public class GetAppNameUtil {

    public static String getAppName() {
        String appName = "UNKNOWN_APPLICATION";
        String path = System.getProperty("user.dir");
        if (path.contains("/")) {
            String[] pathArray = path.split("/");
            if (pathArray.length > 1) {
                appName = pathArray[pathArray.length - 2];
            }
        }
        String property_appName = System.getProperty("APP_NAME");
        if (property_appName != null && !"".equals(property_appName)) {
            appName = property_appName;
        }
        return appName;
    }
}
